package com.lehecai.core.api.event;

import com.lehecai.core.IntegerBeanLabelItem;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by zhangzq on 14-11-14.
 */
public class SubjectType extends IntegerBeanLabelItem {

    private static final Logger logger = LoggerFactory.getLogger(PropType.class.getName());

    private static List<SubjectType> items = new ArrayList<SubjectType>();
    private static List<SubjectType> queryItems = new ArrayList<SubjectType>();

    protected SubjectType(String name, int value, boolean queryOnly) {
        super(SubjectType.class.getName(), name, value);
        queryItems.add(this);
        if (!queryOnly) {
            items.add(this);
        }
    }

    protected SubjectType(String name, int value) {
        this(name, value, false);
    }

    public static SubjectType getItem(int value){
        try {
            return (SubjectType) SubjectType.getResult(SubjectType.class.getName(), value);
        } catch (Exception e) {
            logger.error(e.getMessage(), e);
            return null;
        }
    }

    public static List<SubjectType> getItems() {
        return items;
    }

    public static List<SubjectType> getQueryItems() {
        return queryItems;
    }

    public static final SubjectType ALL = new SubjectType("全部", -1, true);
    public static final SubjectType SPECIAL_CHARACTERS = new SubjectType("人物专题", 0);
    public static final SubjectType COMMON_LIST = new SubjectType("普通列表", 1);
}
